package com.jsonal.config;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

/**
 * @Author: jingji.lin
 * @Description:
 * @Date: 2020/4/21 18:16
 * @Version: 1.0
 */
public class LoginInterceptor extends HandlerInterceptorAdapter {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
        Object handler)
        throws Exception {

        response.setHeader("Access-Control-Allow-Headers",
            "X-Requested-With, accept, content-type, xxxx");
        response.setHeader("Access-Control-Allow-Methods",
            "GET, HEAD, POST, PUT, DELETE, TRACE, OPTIONS, PATCH");
        response.setHeader("Access-Control-Allow-Origin", "<a href='http://127.0.0.1:8081' rel='external nofollow'>http://127.0.0.1:8081</a>");
        response.setHeader("Access-Control-Allow-Credentials", "true");

        return true;
    }
}
